GtkMenu: take csd shadows into account for placement
authorMatthias Clasen <mclasen@redhat.com>
Fri, 6 Jun 2014 22:00:36 +0000 (18:00 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 9 Jun 2014 18:01:42 +0000 (14:01 -0400)
When placing menus, we don't want the shadow to influence
our choice.

https://bugzilla.gnome.org/show_bug.cgi?id=731187

gtk/gtkmenu.c

index fa176418bcd019abe5a312739a823ba0abce2d4d..f1bf2436fac04b944c9ad58c272c2f4f63478afc 100644 (file)
 #include "gtkintl.h"
 #include "gtktypebuiltins.h"
 #include "gtkwidgetprivate.h"
+#include "gtkwindowprivate.h"
 
 #include "deprecated/gtktearoffmenuitem.h"
 
@@ -4474,6 +4475,7 @@ gtk_menu_position (GtkMenu  *menu,
   GdkScreen *pointer_screen;
   GdkRectangle monitor;
   GdkDevice *pointer;
+  GtkBorder border;
 
   widget = GTK_WIDGET (menu);
 
@@ -4485,8 +4487,11 @@ gtk_menu_position (GtkMenu  *menu,
    * the right place to popup the menu.
    */
   gtk_widget_realize (priv->toplevel);
-  requisition.width = gtk_widget_get_allocated_width (widget);
-  requisition.height = gtk_widget_get_allocated_height (widget);
+
+  _gtk_window_get_shadow_width (GTK_WINDOW (priv->toplevel), &border);
+
+  requisition.width = gtk_widget_get_allocated_width (widget)- border.left - border.right;
+  requisition.height = gtk_widget_get_allocated_height (widget) - border.top - border.bottom;
 
   if (pointer_screen != screen)
     {
@@ -4658,6 +4663,9 @@ gtk_menu_position (GtkMenu  *menu,
 
   x = CLAMP (x, monitor.x, MAX (monitor.x, monitor.x + monitor.width - requisition.width));
 
+  x -= border.left;
+  y -= border.top;
+
   if (GTK_MENU_SHELL (menu)->priv->active)
     {
       priv->have_position = TRUE;